
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>

#include "tp_typedef.h"
#include "tp_source_win32.h"
#include "tp_memory.h"

static int tp_source_win32_get(TpSource* thiz)
{
	return -1;
}

static int tp_source_win32_check(TpSource* thiz)
{
	return 0;
}

static TpRet tp_source_win32_dispatch(TpSource* thiz)
{
	MSG msg;

	if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	if (!PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
	{
		Sleep(10);
	}

	return TP_RET_OK;
}

static void tp_source_win32_destroy(TpSource* thiz)
{
	tp_free(thiz);

	return;
}

TpSource* tp_source_win32_create()
{
	TpSource* thiz = (TpSource*)tp_alloc(sizeof(TpSource));
	if (NULL != thiz)
	{
		thiz->get = tp_source_win32_get;
		thiz->check = tp_source_win32_check;
		thiz->dispatch = tp_source_win32_dispatch;
		thiz->destroy = tp_source_win32_destroy;
	}

	return thiz;
}